package com.hust.bridgecheck.serviceImpl.Settings;

import com.hust.bridgecheck.entity.Threshold;
import com.hust.bridgecheck.repository.ThresholdRepository;
import com.hust.bridgecheck.service.Settings.ThresholdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ThresholdServiceImpl implements ThresholdService {
    @Autowired
    private ThresholdRepository thresholdRepository;
    @Override
    public Threshold addThreshold(Threshold threshold) {
        return thresholdRepository.save(threshold);
    }

    @Override
    public void deleteThreshold(Integer thresholdID) {
        thresholdRepository.deleteById(thresholdID);
    }

    @Override
    public Threshold updateThreshold(Threshold threshold) {
        return thresholdRepository.save(threshold);
    }

    @Override
    public Threshold getThresholdByID(Integer thresholdID) {
        return thresholdRepository.findById(thresholdID).get();
    }

    @Override
    public List<Threshold> getAllThreshold() {
        return thresholdRepository.findAll();
    }

    @Override
    public List<Object> getAllDetailThreshold() {
        return thresholdRepository.getAllDetail();
    }

    @Override
    public Threshold getThresoldBySenosorID(String SensorID) {
        return thresholdRepository.getThresholdBySensorID(SensorID);
    }

    @Override
    public List<Object> getThresholdByThresholdName(String TName) {
        return thresholdRepository.getThresholdByThresholdName(TName);
    }

    @Override
    public List<Object> getTresholdByBridgeID(Integer BID) {
        return thresholdRepository.getThresholdByBID(BID);
    }
}
